/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.byd.test.actions;

import com.byd.test.domain.Order;
import com.byd.test.services.OrderService;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author cgx1844568
 * @date 2014-4-24
 * @time 9:17:24
 *
 */
@Controller
@RequestMapping("index")
public class OrderAction {
    
    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
    @Resource
    private OrderService orderService;

    
    @RequestMapping("query")
    public ModelAndView test(){
        ModelAndView modelAndView = new ModelAndView();
        System.out.println("query");
        String message = "oollollkkklll";
        Order order = new Order("AAA","BBB");
        modelAndView.addObject("order", order);
        modelAndView.setViewName("fail");
        modelAndView.addObject(message);
        return modelAndView;
    }
    
    @RequestMapping("helloworld")
    public String helloworld(){
        
        System.out.println("lalalallalaallalahahhahahahhawawawaawawawawa");
        try{
            message = "chengangxiong";
            //orderService.test();
            List<Order> orderList = orderService.queryAll();
            System.out.println("orderList : " + orderList.size());
        }catch (Exception e){
            return "fail";
        }
        System.out.println("ioioioioioioiioiioioioiioioioioioioioioioio" + new Date());
        return "success";
    }
    
    @RequestMapping("mvtest")
    public ModelAndView getFirstPage(HttpServletRequest request) {
                //welcom就是视图的名称（welcom.ftl）
        ModelAndView mv = new ModelAndView("mvtest");
        System.out.println("----------------------------------------ddddddhhhh");
        mv.addObject("name", "My First Spring Mvc");
        return mv;
    }

}
